home *** CD-ROM | disk | FTP | other *** search
/ Clickx 47 / Clickx 47.iso / assets / software / Miro_Installer.exe / Miro_Downloader.exe / theme.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2008-01-10  |  4.5 KB  |  129 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. from gtcache import gettext as _
  5. import logging
  6. import config
  7. import prefs
  8. import app
  9. import views
  10. import indexes
  11. import os
  12. from eventloop import asUrgent
  13. from database import DDBObject
  14. import opml
  15. import iconcache
  16. import resources
  17. import platform
  18. import guide
  19. import feed
  20. import folder
  21. import playlist
  22.  
  23. class ThemeHistory(DDBObject):
  24.     
  25.     def __init__(self):
  26.         DDBObject.__init__(self)
  27.         self.lastTheme = None
  28.         self.pastThemes = []
  29.         self.theme = config.get(prefs.THEME_NAME)
  30.         if self.theme is not None:
  31.             self.theme = unicode(self.theme)
  32.         
  33.         self.pastThemes.append(self.theme)
  34.         self.onFirstRun()
  35.  
  36.     
  37.     def checkNewTheme(self):
  38.         self.theme = config.get(prefs.THEME_NAME)
  39.         if self.theme is not None:
  40.             self.theme = unicode(self.theme)
  41.         
  42.         if self.theme not in self.pastThemes:
  43.             self.pastThemes.append(self.theme)
  44.             self.onFirstRun()
  45.         
  46.         if self.lastTheme != self.theme:
  47.             self.lastTheme = self.theme
  48.             self.onThemeChange()
  49.         
  50.  
  51.     
  52.     def onThemeChange(self):
  53.         self.signalChange()
  54.  
  55.     onThemeChange = asUrgent(onThemeChange)
  56.     
  57.     def onFirstRun(self):
  58.         logging.info('Spawning Miro Guide...')
  59.         guideURL = unicode(config.get(prefs.CHANNEL_GUIDE_URL))
  60.         if guide.getGuideByURL(guideURL) is None:
  61.             guide.ChannelGuide(guideURL, unicode(config.get(prefs.CHANNEL_GUIDE_ALLOWED_URLS)).split())
  62.         
  63.         if config.get(prefs.MAXIMIZE_ON_FIRST_RUN).lower() not in ('false', 'no', '0'):
  64.             app.delegate.maximizeWindow()
  65.         
  66.         if self.theme is not None:
  67.             new_guides = unicode(config.get(prefs.ADDITIONAL_CHANNEL_GUIDES)).split()
  68.             for temp_guide in new_guides:
  69.                 if guide.getGuideByURL(temp_guide) is None:
  70.                     guide.ChannelGuide(temp_guide)
  71.                     continue
  72.             
  73.             if config.get(prefs.DEFAULT_CHANNELS_FILE) is not None and config.get(prefs.THEME_NAME) is not None and config.get(prefs.THEME_DIRECTORY) is not None:
  74.                 importer = opml.Importer()
  75.                 filepath = os.path.join(config.get(prefs.THEME_DIRECTORY), config.get(prefs.THEME_NAME), config.get(prefs.DEFAULT_CHANNELS_FILE))
  76.                 importer.importSubscriptionsFrom(filepath, showSummary = False)
  77.             elif None not in self.pastThemes:
  78.                 self.pastThemes.append(None)
  79.                 self._installDefaultFeeds()
  80.             
  81.         else:
  82.             self._installDefaultFeeds()
  83.  
  84.     
  85.     def _installDefaultFeeds(self):
  86.         initialFeeds = resources.path('initial-feeds.democracy')
  87.         if os.path.exists(initialFeeds):
  88.             urls = subscription.parseFile(initialFeeds)
  89.             if urls is not None:
  90.                 for url in urls:
  91.                     feed.Feed(url, initiallyAutoDownloadable = False)
  92.                 
  93.             
  94.             dialog = dialogs.MessageBoxDialog(_('Custom Channels'), Template(_('You are running a version of $longAppName with a custom set of channels.')).substitute(longAppName = config.get(prefs.LONG_APP_NAME)))
  95.             dialog.run()
  96.             app.controller.initial_feeds = True
  97.         else:
  98.             logging.info('Adding default feeds')
  99.             if platform.system() == 'Darwin':
  100.                 defaultFeedURLs = [
  101.                     u'http://www.getmiro.com/screencasts/mac/mac.feed.rss']
  102.             elif platform.system() == 'Windows':
  103.                 defaultFeedURLs = [
  104.                     u'http://www.getmiro.com/screencasts/windows/win.feed.rss']
  105.             else:
  106.                 defaultFeedURLs = [
  107.                     u'http://www.getmiro.com/screencasts/windows/win.feed.rss']
  108.             defaultFeedURLs.extend([
  109.                 (_('Starter Channels'), [
  110.                     u'http://richie-b.blip.tv/posts/?skin=rss',
  111.                     u'http://feeds.pbs.org/pbs/kcet/wiredscience-video',
  112.                     u'http://www.jpl.nasa.gov/multimedia/rss/podfeed-hd.xml',
  113.                     u'http://www.linktv.org/rss/hq/mosaic.xml'])])
  114.             for default in defaultFeedURLs:
  115.                 print repr(default)
  116.                 if isinstance(default, tuple):
  117.                     defaultFolder = default
  118.                     c_folder = folder.ChannelFolder(defaultFolder[0])
  119.                     for url in defaultFolder[1]:
  120.                         d_feed = feed.Feed(url, initiallyAutoDownloadable = False)
  121.                         d_feed.setFolder(c_folder)
  122.                     
  123.                 d_feed = feed.Feed(default, initiallyAutoDownloadable = False)
  124.             
  125.             playlist.SavedPlaylist(_(u'Example Playlist'))
  126.  
  127.     _installDefaultFeeds = asUrgent(_installDefaultFeeds)
  128.  
  129.